/**
 * @fileOverview 菜单
 * @author goodzsq@gmail.com
 */
var BaseClass = gg.module('ui.jq.Component');
module.exports = gg.createClass({
    attributes: {
        brand: {
            type: 'datatype.String',
            setter: function(v) {
                this.defaultSetter('brand', v);
                var header = this.el.children('.navbar-header');
                header.children('.navbar-brand').html(v);
            }
        },
        left: {
            type: 'ui.jq.Nav',
            setter: function(v, oldValue) {
                if (oldValue && oldValue.el) {
                    oldValue.el.remove();
                }
                if (v && v.el) {
                    v.el.addClass('navbar-nav');
                    this.el.children('.collapse').append(v.el);
                }
            }
        },
        right: {
            type: 'ui.jq.Nav',
            setter: function(v, oldValue) {
                if (oldValue && oldValue.el) {
                    oldValue.el.remove();
                }
                if (v && v.el) {
                    v.el.addClass('navbar-nav navbar-right');
                    this.el.children('.collapse').append(v.el);
                }
            }
        }
    },
    methods: {
        /**
         * @override
         */
        createElement: function() {
            this.el = $('<nav id="' + this.cid + '" class="ui navbar navbar-default">');
            this.el.append('<div class="navbar-header">\
    <button type="button" class="navbar-toggle">\
      <span class="sr-only">Toggle navigation</span>\
      <span class="icon-bar"></span>\
      <span class="icon-bar"></span>\
      <span class="icon-bar"></span>\
    </button>\
    <a class="navbar-brand" href="#">Brand</a>\
  </div>');
            this.el.append('<div class="collapse navbar-collapse">');
        }
    },
    events: {
    }
}, BaseClass, []);